package com.sunzm.demodbencrypted.controller;

import com.sunzm.demodbencrypted.entity.User;
import com.sunzm.demodbencrypted.service.UserService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
public class UserController {
    @Resource
    private UserService userService;

    @PostMapping
    public boolean saveUser(@RequestBody User user) {
        return userService.save(user);
    }

    @GetMapping("/{id}")
    public User getUser(@PathVariable long id) {
        return userService.getById(id);
    }

    @GetMapping("/")
    public List<User> getAllUsers() {
        return userService.getAll();
    }
}
